package main

import (
	"fmt"

	"github.com/gin-gonic/gin"
)

func main() {
	r := gin.Default()
	r.GET("/cookie", func(ctx *gin.Context) {
		cookie, err := ctx.Cookie("gin-cookie")
		if err != nil {
			cookie = "NotSet"
			ctx.SetCookie("gin-cookie", "test", 3600, "/", "localhost", false, true)
			fmt.Println("Cookie=", cookie)
			ctx.String(200, "Set Success.")
			return
		}
		fmt.Println("Cookie=", cookie)
		ctx.String(200, "Get Success.")
	})
	r.Run(":8080")
}
